package com.mrd.spring.config;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.mrd.framework.config.web.MvcConfig;
import com.mrd.framework.config.web.json.JsonFastJsonHttpMessageConverter;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;

import java.util.List;

/**
 * Created by dengdc on 2016/12/14.
 */
@Configuration
public class NewMvcConfigure extends MvcConfig {

	@Override
	public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
		// super.configureMessageConverters(converters);
		converters.add(getFastJsonMessageConverter());
	}

	/**
	 * fastJson相关设置
	 */
	private JsonFastJsonHttpMessageConverter getFastJsonMessageConverter() {
		JsonFastJsonHttpMessageConverter fastJsonConverter = new CustomFastJsonHttpMessageConverter();
		fastJsonConverter.setFeatures(SerializerFeature.DisableCircularReferenceDetect, SerializerFeature.PrettyFormat); // 不进行循环依赖检查
		return fastJsonConverter;
	}
}
